export const randomNumber = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min


export function queryParams(query) {
  const q = []
  for (const key in query) {
    if (query[key])
      q.push(`${key}=${encodeURIComponent(query[key])}`)
  }
  let r = q.join('&')
  r = r ? (`?${r}`) : ''
  return r
}

export function randomString(length) {
  const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  let result = ''
  for (let i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)]
  return result
}